//
//  CSuggesstionViewController.m
//  coninbase_data
//
//  Created by 2.5 on 2021/9/8.
//  Copyright © 2021 ChinaRainbow-iOS. All rights reserved.
//

#import "CSuggesstionViewController.h"

@interface CSuggesstionViewController ()<UITextViewDelegate>
@property (nonatomic,strong)UITextView *textView;
@property (nonatomic,strong)UIButton *sendButton;
@end

@implementation CSuggesstionViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self customeCCUI];
}
-(void)customeCCUI
{
    self.textView = [[UITextView alloc] initWithFrame:CGRectMake(30, 30, self.view.ccwidth-60, 100)];
    self.textView.text = @"Please tell us the defect";
    [self.view addSubview:self.textView];
    self.textView.layer.masksToBounds = YES;
    self.textView.layer.borderWidth = 1;
    self.textView.delegate  =self;
    self.textView.layer.borderColor = [UIColor lightGrayColor].CGColor;
    
    self.sendButton = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 80, 44)];
    [self.sendButton setTitle:@"send" forState:UIControlStateNormal];
    [self.sendButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [self.sendButton addTarget:self action:@selector(sendAction) forControlEvents:UIControlEventTouchUpInside];
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:self.sendButton];
    
}
-(void)textViewDidBeginEditing:(UITextView *)textView
{
    if([self.textView.text isEqualToString:@"Please tell us the defect"]){
        self.textView.text = @"";
    }
}
-(void)sendAction
{
    UIAlertController *avc =[UIAlertController alertControllerWithTitle:@"alert" message:@"thank you!!" preferredStyle:UIAlertControllerStyleAlert];
    
    UIAlertAction *cancel = [UIAlertAction actionWithTitle:@"sure" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
        [self.navigationController popViewControllerAnimated:YES];
    }];
    [avc addAction:cancel];
    [self presentViewController:avc animated:YES completion:nil];
}
-(void)textViewDidEndEditing:(UITextView *)textView
{
    if([textView.text isEqualToString:@"Please tell us the defect"]){
        textView.text = @"";
    }
}
@end
